﻿Friend NotInheritable Class NewDBFForm
    Private DBF_DT As DbfDotNet.DBFDataTable
    Friend Sub New()
        InitializeComponent()
    End Sub
    Friend Sub New(ByVal DBFDataTable As DbfDotNet.DBFDataTable)
        Me.New()
        Me.DBF_DT = DBFDataTable
    End Sub
    Private Sub NewDBFForm_Load(sender As Object, e As EventArgs) Handles Me.Load
        Call PopulateGridView()
    End Sub
    Private Sub PopulateGridView()
        Me.DGV_DataView.Rows.Clear()
        Me.DGV_DataView.Columns.Clear()
        '
        Dim DGVColumn As New Windows.Forms.DataGridViewTextBoxColumn
        DGVColumn.Name = "ROWNUMBER"
        DGVColumn.HeaderText = "ROW #"
        DGVColumn.Width = 120
        Me.DGV_DataView.Columns.Add(DGVColumn)
        '
        For Each Column As Data.DataColumn In Me.DBF_DT.Columns
            DGVColumn = New Windows.Forms.DataGridViewTextBoxColumn
            DGVColumn.Name = Column.ColumnName
            DGVColumn.HeaderText = Column.ColumnName
            DGVColumn.AutoSizeMode = Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells
            Me.DGV_DataView.Columns.Add(DGVColumn)
        Next Column
        '
        Dim X As Int32 = 1
        For Each Row As Data.DataRow In Me.DBF_DT.Rows
            Using DGVRow As New Windows.Forms.DataGridViewRow
                DGVRow.CreateCells(Me.DGV_DataView)
                DGVRow.Cells(0).Value = X
                For Y As Int32 = 0 To Me.DBF_DT.Columns.Count - 1
                    DGVRow.Cells(Y + 1).Value = Row.Item(Y)
                Next Y
                X += 1
                Me.DGV_DataView.Rows.Add(DGVRow)
            End Using
        Next Row
    End Sub
End Class